package cn.example.fragmentnews;

import android.os.Bundle;
import android.support.annotation.Nullable;
import android.support.v4.app.Fragment;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.TextView;

public class NewsContentFragment extends Fragment {

    private View view;
    private TextView tv_news_title,tv_news_content;

    @Nullable
    @Override
    public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
        view = LayoutInflater.from(getContext()).inflate(R.layout.news_content_frag,container,false);
        return view;
    }
    public void refresh(String newsTitle,String newsContent){
        // 拿到新闻布局碎片
        View visibilityLayout = view.findViewById(R.id.visibility_layout);
        visibilityLayout.setVisibility(View.VISIBLE);
        tv_news_title= (TextView) view.findViewById(R.id.tv_news_title);
        tv_news_content= (TextView) view.findViewById(R.id.tv_news_content);
        tv_news_title.setText(newsTitle);  //刷新新闻的标题
        tv_news_content.setText(newsContent); //刷新新闻的头部
    }
}
